<div class="nav">
    <a href="#">商品数据导入</a>
</div>
<div class="add">
    
        <table class="table_add" style="margin-top:0px;">
            <tr>
                <td width="100px"></td>
                <td style="line-height:24px;">
                    导入之前请先下载 <a  href="__PUBLIC__/admin/templete/shop_goods.csv" target="_blank" style="color:Red">商品数据模板下载</a> 填充数据。<BR>
                     数据文件格式为CSV 可用Excel打开，文件编码为UTF-8
                </td>
            </tr>
            <tr>
                <td width="100px">所属类别</td>
                <td>
                     <select name="cat_id" id="cat_id" class="sel1">
                        <option value="">选择类别</option>
                        <foreach name="cat_sel" item="item">
                            <option value="{$item.cat_id}" >{$item.cat_name}</option>
                        </foreach>
                    </select>
                </td>
            </tr>
            <tr>
                <td width="100px">所属品牌</td>
                <td>
                     <select name="brand_id" id="brand_id" class="sel1">
                        <option value="">选择品牌</option>
                        <foreach name="brand_sel" item="item">
                            <option value="{$item.brand_id}" >{$item.brand_name}</option>
                        </foreach>
                    </select>
                </td>
            </tr>
             <tr>
                <td width="100px">显示状态</td>
                <td >
                     <select name="status" id="status" class="sel1">
                        <option value="1">上架</option>
                        <option value="2">下架</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td width="100px">上传CSV数据</td>
                <td >
                    
                    <include file="Public/uploadfile" filetype="file" id="csv"  value="" editvalue="{}" width="100" path="goods_csv" limit="1" thumbw="" thumbh="" msg=""/>

                
                </td>
            </tr>
            <tr id="tr_btn">
                <td></td>
                <td><input type="button" onclick="export_csv()" class="btn1" value="开始导入" /></td>
            </tr>
            <tr id="tr_result" style="display:none;">
                <td></td>
                <td><div id="export_result" style="line-height:1.5;"></div></td>
            </tr>
        </table>
   
</div>
<script type="text/javascript">
    var url_export_ajax = "{:U('export_ajax')}";
    function export_csv() {
        var filename = $("#csv").val();
        if(filename == '') {
            alert("请上传CSV数据！");
            return false;
        }
        var cat_id = $("#cat_id").val();
        var brand_id = $("#brand_id").val();
        var status = $("#status").val();
        $("#tr_btn").hide();
        $("#tr_result").show();
        $("#export_result").html("");
        $("#export_result").append("数据正在开始导入...<br />")
        $.ajax({
            url:url_export_ajax,
            data:{filename:filename,cat_id:cat_id,brand_id:brand_id,status:status},
            type:"GET",
            success:function(result) {
                $("#export_result").append(result+'<br />');
                $("#tr_btn").show();
            }
        })
    }
    
</script>